package com.jwell.panprovider.ui.activity

import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import com.jwell.panprovider.application.UserState
import com.jwell.driverapp.ui.base.BaseActivity
import com.jwell.panprovider.R
import com.jwell.panprovider.application.App
import com.jwell.panprovider.application.ConstValue
import com.jwell.panprovider.tools.DataModel
import java.util.*
import kotlin.concurrent.timerTask

/**
 * 启动页
 */
class StartActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
        setContentView(R.layout.activity_start)
        setTransportStatusBar()
        Timer().schedule(timerTask {
            when (DataModel.getInstance().userState) {
                null -> skipToLogin(true)
                UserState.LOGGED -> {
//                    skipToMain(null)
                    finish()
                    var intent = Intent(App.instance, MainActivity::class.java)
                    startActivity(intent)
                }
                UserState.LOGOUT -> {
//                    skipToMain(null)
                    skipToLogin(true)
                }
                UserState.FIRST -> {
                    skipToLogin(true)
//                    skipToMain(null)
//                    var intent = Intent(baseContext, GuideActivity::class.java)
//                    startActivity(intent)
//                    finish()
                }
            }
        }, ConstValue.START_WAIT_TIME)
    }
}
